﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 智信科技物流系统
{
    public partial class Repeat : Form
    {
        public Repeat()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Repeat_Load(object sender, EventArgs e)
        {
            update();
            timer1.Interval = 1000;//更新时间
            timer1.Enabled = true;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            update();
        }
        private void update()
        {
            this.grd_repeat.Rows.Clear();
            for (int i = 0; i < repeatini.initype.Count; i++)
            {
                if (repeatini.ininum[i] > 0)//隐藏删除的数据，数据删除时，因为有一个sleep事件，不能及时删除，先隐藏掉
                {
                    grd_repeat.Rows.Add(repeatini.initype[i], repeatini.inicontent[i], repeatini.initime[i] + "分钟", repeatini.ininum[i] + "次", repeatini.id[i]);
                }

            }
        }

        private void btn_delete_Click(object sender, EventArgs e)
        {
            if (grd_repeat.SelectedRows.Count < 1)
            {
                MessageBox.Show("请选择一个重发项目");
                return;
            }
            int id = repeatini.id[Convert.ToInt32(grd_repeat.Rows[grd_repeat.SelectedRows[0].Index].Cells[4].Value)];
            repeatini.ininum[id] = 0;
            update();
        }

    }
}
